home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfaces / Components.p < prev    next >
Encoding:
Text File  |  1993-09-16  |  8.1 KB  |  239 lines  |  [TEXT/MPS ]

  1.  Created: Tuesday, October 13, 1992
  2.  Components.p
  3.  Pascal Interface to the Macintosh Libraries
  4.  
  5.  Copyright Apple Computer, Inc. 1991, 1992
  6.  All rights reserved
  7. }
  8.  
  9.  
  10. {$IFC UNDEFINED UsingIncludes}
  11. {$SETC UsingIncludes := 0}
  12. {$ENDC}
  13.  
  14. {$IFC NOT UsingIncludes}
  15.  UNIT Components;
  16.  INTERFACE
  17. {$ENDC}
  18.  
  19. {$IFC UNDEFINED UsingComponents}
  20. {$SETC UsingComponents := 1}
  21.  
  22. {$I+}
  23. {$SETC ComponentsIncludes := UsingIncludes}
  24. {$SETC UsingIncludes := 1}
  25. {$IFC UNDEFINED UsingTypes}
  26. {$I $$Shell(PInterfaces)Types.p}
  27. {$ENDC}
  28. {$IFC UNDEFINED UsingTypes}
  29. {$I $$Shell(PInterfaces)Memory.p}
  30. {$ENDC}
  31. {$SETC UsingIncludes := ComponentsIncludes}
  32.  
  33. CONST
  34. gestaltComponentMgr = 'cpnt';
  35.  
  36. kAnyComponentType =            0;
  37. kAnyComponentSubType =         0;
  38. kAnyComponentManufacturer =    0;
  39. kAnyComponentFlagsMask =    0;
  40.  
  41. cmpWantsRegisterMessage = $80000000;
  42.  
  43.  
  44. TYPE
  45. ComponentDescription = RECORD
  46.  componentType: OSType;                                { A unique 4-byte code indentifying the command set }
  47.  componentSubType: OSType;                            { Particular flavor of this instance }
  48.  componentManufacturer: OSType;                        { Vendor indentification }
  49.  componentFlags: LONGINT;                            { 8 each for Component,Type,SubType,Manuf/revision }
  50.  componentFlagsMask: LONGINT;                        { Mask for specifying which flags to consider in search, zero during registration }
  51.  END;
  52.  
  53. ResourceSpec = RECORD
  54.  resType: OSType;                                    { 4-byte code  }
  55.  resId: INTEGER;                                    {    }
  56.  END;
  57.  
  58. ComponentResourcePtr = ^ComponentResource;
  59. ComponentResourceHandle = ^ComponentResourcePtr;
  60. ComponentResource = RECORD
  61.  cd: ComponentDescription;                            { Registration parameters }
  62.  component: ResourceSpec;                            { resource where Component code is found }
  63.  componentName: ResourceSpec;                        { name string resource }
  64.  componentInfo: ResourceSpec;                        { info string resource }
  65.  componentIcon: ResourceSpec;                        { icon resource }
  66.  END;
  67.  
  68. Component = ^privateComponentRecord;
  69. ComponentInstance = ^privateComponentInstanceRecord;
  70.  
  71. { Structure received by Component:  }
  72. ComponentParameters = PACKED RECORD
  73.  flags: CHAR;                                        { call modifiers: sync/async, deferred, immed, etc }
  74.  paramSize: CHAR;                                    { size in bytes of actual parameters passed to this call }
  75.  what: INTEGER;                                        { routine selector, negative for Component management calls }
  76.  params: ARRAY [0..0] OF LONGINT;                    { actual parameters for the indicated routine }
  77.  END;
  78.  
  79. ComponentResult = LONGINT;
  80.  
  81. ComponentRoutine = ProcPtr;
  82.  
  83. ComponentFunction = ProcPtr;
  84.  
  85.  
  86. {******************************************************
  87. * Required Component routines
  88. ******************************************************}
  89.  
  90. CONST
  91. kComponentOpenSelect = -1;                            { ComponentInstance for this open }
  92. kComponentCloseSelect = -2;                            { ComponentInstance for this close }
  93. kComponentCanDoSelect = -3;                            { selector # being queried }
  94. kComponentVersionSelect = -4;                        { no params }
  95. kComponentRegisterSelect = -5;                        { no params }
  96. kComponentTargetSelect = -6;                        { ComponentInstance for top of call chain }
  97.  
  98. { Set Default Component flags }
  99. defaultComponentIdentical = 0;
  100. defaultComponentAnyFlags = 1;
  101. defaultComponentAnyManufacturer = 2;
  102. defaultComponentAnySubType = 4;
  103. defaultComponentAnyFlagsAnyManufacturer = defaultComponentAnyFlags+defaultComponentAnyManufacturer;
  104. defaultComponentAnyFlagsAnyManufacturerAnySubType = defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType;
  105.  
  106. { errors from component manager & components }
  107. invalidComponentID = -3000;
  108. validInstancesExist = -3001;
  109. componentNotCaptured = -3002;
  110. componentDontRegister = -3003;
  111.  
  112. badComponentInstance = $80008001;
  113. badComponentSelector = $80008002;
  114.  
  115.  
  116. { *******************************************************
  117. *                                                     *
  118. *              APPLICATION LEVEL CALLS                *
  119. *                                                     *
  120. *******************************************************
  121. * Component Database Add, Delete, and Query Routines 
  122. *******************************************************
  123.  }
  124. FUNCTION RegisterComponent(cd: ComponentDescription;componentEntryPoint: ComponentRoutine;
  125.  global: INTEGER;componentName: Handle;componentInfo: Handle;componentIcon: Handle): Component;
  126.  INLINE $7001,$A82A;
  127. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle;global: INTEGER): Component;
  128.  INLINE $7012,$A82A;
  129. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  130.  INLINE $7002,$A82A;
  131.  
  132. FUNCTION FindNextComponent(aComponent: Component;looking: ComponentDescription): Component;
  133.  INLINE $7004,$A82A;
  134. FUNCTION CountComponents(looking: ComponentDescription): LONGINT;
  135.  INLINE $7003,$A82A;
  136.  
  137. FUNCTION GetComponentInfo(aComponent: Component;cd: ComponentDescription;
  138.  componentName: Handle;componentInfo: Handle;componentIcon: Handle): OSErr;
  139.  INLINE $7005,$A82A;
  140. FUNCTION GetComponentListModSeed: LONGINT;
  141.  INLINE $7006,$A82A;
  142.  
  143.  
  144. { *******************************************************
  145. * Component Instance Allocation and dispatch routines 
  146. *******************************************************
  147.  }
  148. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  149.  INLINE $7007,$A82A;
  150. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  151.  INLINE $7008,$A82A;
  152.  
  153. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  154.  INLINE $700A,$A82A;
  155.  
  156.  
  157. {  direct calls to the Components  }
  158. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance;ftnNumber: INTEGER): LONGINT;
  159.  INLINE $2F3C,$2,$FFFD,$7000,$A82A;
  160. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  161.  INLINE $2F3C,$0,$FFFC,$7000,$A82A;
  162. FUNCTION ComponentSetTarget(ci:ComponentInstance; target:ComponentInstance):LONGINT;
  163.  INLINE $2F3C,$4,$FFFA,$7000,$A82A;
  164.  
  165.  
  166. {****************************************************
  167. *                                                    *
  168. *               CALLS MADE BY Components             *
  169. *                                                    *
  170. ******************************************************}
  171.  
  172.  
  173. { *******************************************************
  174. * Component Management routines
  175. *******************************************************
  176.  }
  177. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance;
  178.  theError: OSErr);
  179.  INLINE $700B,$A82A;
  180.  
  181. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  182.  INLINE $7010,$A82A;
  183. PROCEDURE SetComponentRefcon(aComponent: Component;theRefcon: LONGINT);
  184.  INLINE $7011,$A82A;
  185.  
  186. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  187.  INLINE $7015,$A82A;
  188. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  189.  INLINE $7018,$A82A;
  190.  
  191.  
  192. { *******************************************************
  193. * Component Instance Management routines
  194. *******************************************************
  195.  }
  196. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  197.  INLINE $700C,$A82A;
  198. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance;
  199.  theStorage: Handle);
  200.  INLINE $700D,$A82A;
  201.  
  202. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  203.  INLINE $700E,$A82A;
  204. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance;
  205.  theA5: LONGINT);
  206.  INLINE $700F,$A82A;
  207.  
  208. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  209.  INLINE $7013,$A82A;
  210.  
  211. {  useful helper routines for convenient method dispatching  }
  212. FUNCTION CallComponentFunction(params: ComponentParameters;func: ComponentFunction): LONGINT;
  213.  INLINE $70FF,$A82A;
  214. FUNCTION CallComponentFunctionWithStorage(storage: Handle;params: ComponentParameters;
  215.  func: ComponentFunction): LONGINT;
  216.  INLINE $70FF,$A82A;
  217. FUNCTION DelegateComponentCall(originalParams: ComponentParameters;
  218.  ci: ComponentInstance): LONGINT;
  219.  INLINE $7024,$A82A;
  220.  
  221. FUNCTION SetDefaultComponent(aComponent: Component;flags: INTEGER): OSErr;
  222.  INLINE $701E,$A82A;
  223. FUNCTION  OpenDefaultComponent(componentType: OSType; componentSubType: OSType ) : ComponentInstance;
  224.  INLINE $7021,$A82A;
  225. FUNCTION CaptureComponent(capturedComponent: Component;capturingComponent: Component): Component;
  226.  INLINE $701C,$A82A;
  227. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  228.  INLINE $701D,$A82A;
  229. FUNCTION RegisterComponentResourceFile(resRefNum:INTEGER;global:INTEGER):LONGINT;
  230.  INLINE $7014,$A82A;
  231.  
  232. {$ENDC} { UsingComponents }
  233.  
  234. {$IFC NOT UsingIncludes}
  235.  END.
  236. {$ENDC}
  237.  
  238.